#!/bin/bash

# 构建并运行Golang后端服务器

echo "Starting Golang backend server..."

# 检查环境变量文件
if [ ! -f .env ]; then
    echo "Creating .env file..."
    cat > .env << EOF
AES_KEY=32_byte_long_key_1234567890123456
AES_IV=16_byte_long_iv_
PORT=8080
GIN_MODE=debug
EOF
fi

# 安装依赖
echo "Installing Go dependencies..."
go mod tidy

# 运行测试
echo "Running tests..."
go test ./... -v

# 构建并运行
echo "Building and running server..."
go run main.go
